#include "stdafx.h"
#include "ssautoi.h"						// Internal SourceSafe automation defs.
#include "MSVSOrig.h"

MSVSOrig::MSVSOrig(void)
{
}

MSVSOrig::~MSVSOrig(void)
{
}
HINSTANCE hDLL;

void MSVSOrig::CallFunc(char* lpProcName, void* prop1, int prop2, int prop3)
{
	typedef void (*LPFill)(void*,int,int);
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			Filli(prop1, prop2, prop3);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
}
int  MSVSOrig::CallFunc(char* lpProcName, char* prop1, struct HINSTANCE__ * prop2)
{
	typedef int (*LPFill)(char*, struct HINSTANCE__ *);
	int r_Value;
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			r_Value = Filli(prop1, prop2);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
	return r_Value;
}

int  MSVSOrig::CallFunc(char* lpProcName, char const * prop1,char * prop2,char * prop3)
{
	typedef int (*LPFill)(char const * ,char * ,char * );
	int r_Value;
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			r_Value = Filli(prop1, prop2, prop3);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
	return r_Value;
}
void MSVSOrig::CallFunc(char* lpProcName, struct HINSTANCE__ * prop1, struct FONTINFO * prop2)
{
	typedef void (*LPFill)(struct HINSTANCE__ *, struct FONTINFO * );
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			Filli(prop1, prop2);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
}


int  MSVSOrig::CallFunc(char* lpProcName, char * prop1,char const * prop2,int prop3)
{
	typedef int (*LPFill)(char *,char const *,int);
	int r_Value;
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			r_Value = Filli(prop1, prop2, prop3);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
	return r_Value;
}

int  MSVSOrig::CallFunc(char* lpProcName, char * prop1,char const * prop2,int prop3,int prop4)
{
	typedef int (*LPFill)(char *,char const *,int,int);
	int r_Value;
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			r_Value = Filli(prop1, prop2, prop3, prop4);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
	return r_Value;
}
int  MSVSOrig::CallFunc(char* lpProcName, struct HINSTANCE__ * prop1,char * prop2,unsigned int prop3,int prop4)
{
	typedef int (*LPFill)(struct HINSTANCE__ *,char *,unsigned int,int);
	int r_Value;
	LPFill Filli;
	hDLL = LoadLibraryA(LPCSTR("ssapiold.dll"));
	assert(hDLL);
	if (hDLL)
	{
		Filli = (LPFill)GetProcAddress(hDLL, lpProcName);
		assert(Filli);
		if (Filli)
			r_Value = Filli(prop1, prop2, prop3, prop4);
		else 
		{
			Trace::Write("\tFunction address not found in DLL, %s", LPWSTR(lpProcName));
			FreeLibrary(hDLL);
		}
	}
	else 
		Trace::Write("\tDLL failed to load, %s", LPWSTR(lpProcName));

	if(hDLL) 
	{
		FreeLibrary(hDLL);
		Trace::Write("\tLibrary freed, %s", LPWSTR(lpProcName));
	}
	return r_Value;
}
